package com.gragra.sampling.binary.tests;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import com.gragra.sampling.binary.AVLTripleCounter;
/**
 * 
 * @author Christoph Teichmann
 * 17.09.2013
 */
public class TestAVLTripleCounter
{
	/**
	 * 
	 */
	private AVLTripleCounter co = new AVLTripleCounter();
	@Before
	public void setUp() throws Exception
	{
		co = new AVLTripleCounter();
		co.changeVal((short) 3,(short) 7,(short) 5, 1.0);
		co.changeVal((short) 5,(short) 10,(short) 5, 11.0);
		co.changeVal((short) 3,(short) 7,(short) 5, 4.0);
		co.changeVal((short) 5,(short) 10,(short) 5, -11.0);
	}
	@Test
	public void testSetVal()
	{
		co.setVal((short) 3,(short) 7,(short) 4, 17.0);
		assertEquals(co.getAmount((short) 3,(short) 7,(short) 4),17.0,0.00001);
		assertEquals(co.getAmount((short) 5,(short) 10,(short) 5),0.0,0.000001);
	}
	@Test
	public void testClear()
	{
		co.clear();
		assertEquals(co.getAmount((short) 3,(short) 7,(short) 4),0.0,0.00001);
		assertEquals(co.getAmount((short) 5,(short) 10,(short) 5),0.0,0.000001);
	}
}